<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="author" content="blog.anchen8.net" />

    <title>无标题 5</title>
</head>
<link rel="stylesheet" href="__CSS__/pintuer.css"/>
<link rel="stylesheet" href="__CSS__/admin.css"/>
<script src="__JS__/jquery-1.8.3.min.js"></script>
<script src="__JS__/jquery.js"></script>
<script src="__JS__/pintuer.js"></script>
<link href="__JS__/bootstrap-3.3.4.css" rel="stylesheet"/>
<!--<script type="text/javascript" src="__JS__/merchant_submit/merchant_submit.js" charset="utf-8"></script>-->
<!--<script type="text/javascript" src="__JS__/jquery.validate.js" charset="utf-8"></script>-->
<script src="__JS__/layer/layer.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=hsaUPForKQCFPvo0bCAowpe00AvKQugP"></script>
<body>
{volist name="date" id="v"}
<div class="panel admin-panel">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>修改客房内容</strong></div>
    <div class="body-content">
        <form method="post" class="form-x" action="{:url('Mailbox/modify_save')}?mailbox_id={$v.id}" enctype="multipart/form-data" id="form">
            <div class="form-group">
                <div class="label">
                    <label>客房名称：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="{$v.r_name}" name="r_name" id="r_name" data-validate="required:请输入内容" />
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>发布酒店名称：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="{$v.name}" name="name" id="name" readonly>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>客房图片：</label>
                </div>
                <div class="field" style="position: relative;">
                    <input type="button" class="button bg-blue margin-left" id="image1" value="+ 浏览上传"  style="float:left;position: absolute;z-index: 1;"/>
                    <input id="file0" type="file" name="file" value="{$v.img}" onclick="changeSrc()" style="position: absolute;z-index:21;opacity: 0;padding: 10px 15px 10px 10px;width: 115.532px;"/>
                    <img src="__UPLOADS__/{$cc[$key]['r_img'][0]}"  id="img0"  width="100px" height="60px" style="border-radius: 5px;position: absolute;z-index:21;left: 120px;top: -10px;"><br>
                    <!--<img src="__UPLOADS__src"  class="img-circle m-t-xs img-responsive" style="height:60px;width:100px;border-radius: 10px;position: absolute;z-index:21;left: 120px;top: -10px;">-->
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>酒店电话：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" name="phone" id="phone" value="{$v.phone}"  readonly>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>酒店邮箱：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" name="mail" id="mail" value="{$v.Mail}"  readonly>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>客房介绍：</label>
                </div>
                <div class="field">
                    <textarea class="input" name="merchant_introduction" id="merchant_introduction">{$v.r_introduce}</textarea>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>详细地址：</label>
                </div>
                <div class="field">
                    <input type='text' class="input w50" value='{$v.detailed}' name='sever_add' id='sever_add' readonly>
                    <!--<input type='button' class="input w50" value='点击显示地图获取地址经纬度' id='open'>-->
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <input type="submit" class="button bg-main icon-check-square-o" id="admin_add_tj" value="提交">
                </div>
            </div>
            <div id='allmap' style='width: 50%; height: 50%; position: absolute; display: none;top: 86px;left: 590px'></div>
        </form>
    </div>
</div>
{/volist}
<script src="__JS__/distpicker.data.js"></script>
<script src="__JS__/distpicker.js"></script>
<script src="__JS__/main.js"></script>
<script type="text/javascript">
    function changeSrc()
    {
        document.getElementById("file0").src="__UPLOADS__src";
    }
    $("#file0").change(function(){
        // getObjectURL是自定义的函数，见下面
        // this.files[0]代表的是选择的文件资源的第一个，因为上面写了 multiple="multiple" 就表示上传文件可能不止一个
        // ，但是这里只读取第一个
        var objUrl = getObjectURL(this.files[0]) ;
        // 这句代码没什么作用，删掉也可以
        // console.log("objUrl = "+objUrl) ;
        if (objUrl) {
            // 在这里修改图片的地址属性
            $("#img0").attr("src", objUrl) ;
        }
    }) ;
    //建立一個可存取到該file的url
    function getObjectURL(file) {
        var url = null ;
        // 下面函数执行的效果是一样的，只是需要针对不同的浏览器执行不同的 js 函数而已
        if (window.createObjectURL!=undefined) { // basic
            url = window.createObjectURL(file) ;
        } else if (window.URL!=undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file) ;
        } else if (window.webkitURL!=undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file) ;
        }
        return url ;
    }
    function validate() {
        var sever_add = document.getElementsByName('sever_add')[0].value;
        if (isNull(sever_add)) {
            alert('请选择地址');
            return false;
        }
        return true;
    }

    //判断是否是空
    function isNull(a) {
        return (a == '' || typeof(a) == 'undefined' || a == null) ? true : false;
    }

    document.getElementById('open').onclick = function () {
        if (document.getElementById('allmap').style.display == 'none') {
            document.getElementById('allmap').style.display = 'block';
        } else {
            document.getElementById('allmap').style.display = 'none';
        }
    }

    var map = new BMap.Map("allmap");
    var geoc = new BMap.Geocoder();   //地址解析对象
    var markersArray = [];
    var geolocation = new BMap.Geolocation();


    var point = new BMap.Point(104.06,30.67);
    map.centerAndZoom(point, 11); // 中心点
    geolocation.getCurrentPosition(function (r) {
        if (this.getStatus() == BMAP_STATUS_SUCCESS) {
            var mk = new BMap.Marker(r.point);
            map.addOverlay(mk);
            map.panTo(r.point);
            map.enableScrollWheelZoom(true);
        }
        else {
            alert('failed' + this.getStatus());
        }
    }, {enableHighAccuracy: true})
    map.addEventListener("click", showInfo);


    //清除标识
    function clearOverlays() {
        if (markersArray) {
            for (i in markersArray) {
                map.removeOverlay(markersArray[i])
            }
        }
    }
    //地图上标注
    function addMarker(point) {
        var marker = new BMap.Marker(point);
        markersArray.push(marker);
        clearOverlays();
        map.addOverlay(marker);
    }
    //点击地图时间处理
    function showInfo(e) {
        document.getElementById('lng').value = e.point.lng;
        document.getElementById('lat').value =  e.point.lat;
        geoc.getLocation(e.point, function (rs) {
            var addComp = rs.addressComponents;
            var address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;
            if (confirm("确定要地址是" + address + "?")) {
                document.getElementById('allmap').style.display = 'none';
                document.getElementById('sever_add').value = address;
            }
        });
        addMarker(e.point);
    }

</script>

</body>
</html>